package cn.tedu.reflection;
/*本类用于学习反射的物料类*/
public class Student {
    //1,定义成员变量
    private String name;
    public int age;
    public int age2;

    //2,给被封装的属性提供get与set方法
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    //3,添加本类的无参构造与全参构造
    public Student(){}



    public Student(String name, int age) {
        this.name = name;
        this.age = age;

    }
    public Student(String name, int age,int age2) {
        this.name = name;
        this.age = age;
        this.age2 = age2;
    }
    //4,提供本类的普通方法
    public void play(){
        System.out.println("今天大结局,放学后我要写两行代码玩玩~");
    }
    public void eat(int n){
        System.out.println("今天要吃"+n+"道好菜");
    }
    //5,为了查看对象时打印具体的类型 属性 属性值,所以重写toString()



    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", age2=" + age2 +
                '}';
    }
}

